package com.springboot.controller.annotations;

import com.springboot.mapper.Annotations.AnnotationsMapper;
import com.springboot.pojo.Annotations;
import com.springboot.service.Annotations.AnnotationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/postman/annotations")
public class AnnotationsController {

    private AnnotationsService annotationsService;

    @Autowired
    public AnnotationsController(AnnotationsService annotationsService) {
        this.annotationsService = annotationsService;
    }

    @GetMapping("/all")
    public List<Annotations> getAllAnnotation() {
        return annotationsService.getAllAnnotations();
    }

    @GetMapping("/{annotationId}")
    public AnnotationsMapper getAnnotationsById(@PathVariable Long annotationId) {
        return (AnnotationsMapper) annotationsService. getAnnotationById(annotationId);
    }

    @PostMapping("/add")
    public void addAnnotation(@RequestBody AnnotationsMapper annotation) {
        annotationsService.addAnnotation((Annotations) annotation);
    }

    @PutMapping("/update")
    public void updateAnnotation(@RequestBody AnnotationsMapper annotation) {
        annotationsService.updateAnnotation((Annotations) annotation);
    }

    @DeleteMapping("/delete/{annotationId}")
    public void deleteAnnotation(@PathVariable Long annotationId) {
        annotationsService.deleteAnnotation(annotationId);
    }
}
